package com.xiaoying.server.publish.servlet;


import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class LoadServlet extends HttpServlet  {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private static Log log = LogFactory.getFactory().getInstance(LoadServlet.class);
    
    private Dispatcher dispatcher;

	public void init(ServletConfig cfg) throws ServletException {
//	    super.init(cfg);
//		configFile = cfg.getServletContext().getRealPath("WEB-INF") 
//		             + System.getProperty("file.separator") 		//获取路径的符号/或者\(和系统有关)
//		             + cfg.getInitParameter("configFile");
//		CommonHelper.APPPATH = cfg.getServletContext().getRealPath("WEB-INF");
//	    ServletContext servletContext = cfg.getServletContext();
		startServer();
	}

	public void startServer() {
	    log.info("XiaoYing文件上传服务器启动...");
		try {
//		    Dispatcher dispatcher = Dispatcher.getInstance();
            dispatcher.init();
            dispatcher.startup();
        } catch (Exception e) {
            log.error("XiaoYing文件上传服务器启动异常!!!",e);
            e.printStackTrace();
        }		
		log.info("XiaoYing文件上传服务器启动成功。");
	}

	public Dispatcher getDispatcher() {
		return dispatcher;
	}

	public void setDispatcher(Dispatcher dispatcher) {
		this.dispatcher = dispatcher;
	}

	
}
